package com.bugreport.utils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.unitils.UnitilsJUnit4;
import org.unitils.spring.annotation.SpringApplicationContext;

public class BugReportExceptionTestCase extends UnitilsJUnit4 {

	// useless attribute but required to force context loading
	@SuppressWarnings("unused")
	@SpringApplicationContext("spring-message-factory.xml")
	private ApplicationContext applicationContext;

	@Test
	public void newExceptionWithCode301() {

		// given
		int code = 301;
		String url = "foo.bar";

		// when
		BugReportException exception = new BugReportException(code, url);

		// then
		assertNotNull(exception);
		assertEquals(code, exception.getCode());
		assertEquals("Unable to successfully invoke Axis remote service at 'foo.bar'.", exception.getMessage());
	}
}
